unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Db, IfxConnection, IfxCustomDataset, Grids, DBGrids, StdCtrls,
  IfxQuery, IfxUpdateSQL, LXDataSetImpl, LXSQLProcessor, IfxSQL;

type
  TFormMain = class(TForm)
    IfxConnection1: TIfxConnection;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    IfxQuery1: TIfxQuery;
    IfxSQL1: TIfxSQL;
    IfxQuery2: TIfxQuery;
    DataSource2: TDataSource;
    DBGrid2: TDBGrid;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation

uses IfxTable;

{$R *.DFM}

procedure TFormMain.Button1Click(Sender: TObject);
var
  dw1, dw2: DWORD;
  I: Integer;
begin
  IfxConnection1.Open;

  dw1 := GetTickCount;
  {}
  with TIfxTable.Create(nil) do
    try
      Connection := IfxConnection1;
      TableName := 'customer';
      for I := 0 to 500 do
      begin
        Open;

        with TIfxTable.Create(nil) do
          try
            Connection := IfxConnection1;
            TableName := 'customer';
            Open;
            FetchAll;
          finally
            Free;
          end;

        Close;
      end;
    finally
      Free;
    end;
    
  {
  for I := 0 to 1000 do
    with TIfxQuery.Create(nil) do
      try
        Connection := IfxConnection1;
        SQL.Text := 'update customer set fname=''asdfasdf'' where 1=0';
        ExecSQL;

        with TIfxQuery.Create(nil) do
          try
            Connection := IfxConnection1;
            SQL.Text := 'update customer set fname=''asdfasdf'' where 1=0';
            ExecSQL;
          finally
            Free;
          end;

        FetchAll;
      finally
        Free;
      end;
  {}

  dw2 := GetTickCount;
  ShowMessage(IntToStr(dw2 - dw1));
end;

procedure TFormMain.Button2Click(Sender: TObject);
begin
  IfxQuery1.Active := not IfxQuery1.Active;
  IfxQuery2.Active := IfxQuery1.Active;
end;

procedure TFormMain.Button3Click(Sender: TObject);
begin
  with IfxConnection1 do
    ShowMessage(FloatToStr(StatementCacheHits / StatementAllocations));
end;

end.
